package com.SwaggerTest.Controller;

import com.SwaggerTest.bean.Parent;
import com.SwaggerTest.bean.Person;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@Api(value = "Swagger使用请求参数的案例", tags = "不同形式的参数页面展示不同")
@RestController
@RequestMapping("/HelloSwagger")
public class HelloSwaggerBean {

    @ApiOperation(value = "RequestBody接受参数", notes = "RequestBody")
    @ApiResponses({
            @ApiResponse(code = 200,message = "兄弟你太棒了"),
            @ApiResponse(code = 400,message = "兄弟400错误了请检查参数")
    })
    @RequestMapping(value = "/helloBean"  ,method = RequestMethod.POST)
    public Person HelloSwaggerRequestBody(@RequestBody Parent Parent) {

        Person p = new Person();
        p.setParent(Parent);
        return   p;
    }
    @ApiOperation(value = "query接受参数", notes = "query")
    @ApiImplicitParams(
            value = {
                    @ApiImplicitParam(name = "name", value = "姓名", dataType = "string", paramType = "query", defaultValue = "小明的爸爸", required = true),
                    @ApiImplicitParam(name = "age", value = "年龄", dataType = "string", paramType = "query", defaultValue = "58", required = true),
                    @ApiImplicitParam(name = "adress", value = "地址", dataType = "string", paramType = "query", defaultValue = "地球村888号", required = true),
                    @ApiImplicitParam(name = "email", value = "email", dataType = "string", paramType = "query", defaultValue = "www@chiji.com", required = true)})

    @ApiResponses({
            @ApiResponse(code = 200,message = "兄弟你太棒了"),
            @ApiResponse(code = 400,message = "兄弟400错误了请检查参数")
    })
    @RequestMapping(value = "/helloBeanUrl"  ,method = RequestMethod.GET)
    public Person HelloSwaggerUrl( Parent Parent) {

        Person p = new Person();
        p.setParent(Parent);
        return   p;
    }


}
